1. Field of the Invention
The present invention relates to a demand paging technique. More particularly, the present invention relates to a demand paging method and terminal for processing at least one of code and data requiring a real-time response through the efficient use of a limited capacity of Random Access Memory (RAM).
2. Description of the Related Art
All devices store data, which can be either data related to characteristics of a device or executable code required for the execution of functions of a device. Devices use a virtual memory technique to efficiently store and manage data.
In the virtual memory technique, a physical storage medium (a volatile storage medium) and a nonvolatile storage medium are mapped to manage data and code and demand paging is performed to retrieve only data that is needed. Demand paging is a method for reading only data that is required for a specific process from the nonvolatile storage medium, temporarily downloading the data to the physical storage medium, and reading the data from the physical storage medium. In the execution of demand paging, the only information read is information that is required for a process and for rapidly processing the information in a high speed RAM. Then, after a preset period of time lapses, information temporarily stored in a RAM is deleted. In other words, demand paging refers to a memory management technique for storing data of the device in a physical storage medium and for reading only part of the data from the physical storage medium whenever it is needed.
The nonvolatile storage medium of the device stores executable code and data provided from several sources. However, the code and data stored in the nonvolatile storage medium are not all used in a process that is executed during a specific period of time. Among the code, there may be a code necessary for only a specific case, for example, only when a process starts or an event occurs. Thus, it is inefficient to load the entirety of the code, which may not all be required, into the physical storage medium. Further, if the procedure is repeatedly executed each time a process within the device needs to be carried out, this may waste resources of the device. Accordingly, only necessary information is loaded into the physical storage medium at a specific time point using the demand paging technique.
With the development of mobile equipment, more functions are gradually added to the mobile equipment to realize a more convenient mobile environment. Adding more functions to the mobile equipment requires an increase in the amount of software or a demand for RAM. This is followed by an increase in an amount of RAM needed in a device. However, RAM is a relatively expensive resource.
In recent years, a demand for cheap equipment is also increasing at the same time. Thus, in order to meet the two conflicting requirements, RAM has to be more efficiently used in order to enable a lesser amount of RAM to be needed.
In a general environment such as a Personal Computer (PC), which is not the mobile environment, the above requirements are satisfied using a virtual memory technique. In the virtual memory technique, disk resources that are slower but much cheaper than RAM are virtualized as if they were RAM and the contents of a disk are mapped to a partial buffer of a RAM and used whenever they are needed. Only part of the code stored in the disk is required to process a specific process. Thus, the virtual memory technique shifts only content needed at a specific time point from the disk to the RAM and performs a process, thereby enhancing a degree of use of the RAM.
In the mobile environment, a Not AND (NAND) flash memory functions as a disk of the mobile equipment. The NAND flash memory, a type of a nonvolatile storage medium, can store a large capacity of data despite its simple structure. The NAND flash memory also has an advantage of excellent durability, large capacity, and relatively low cost as compared to a magnetic storage device.
However, with the NAND flash memory, write performance is comparatively slower than a read performance and frequent writes shorten its operational life and therefore, it is difficult for the mobile environment to utilize the virtual memory technique of the general PC environment. Thus, mobile equipment primarily applies a demand paging technique of caching only data, such as code that is in read only region, having no change in the content of RAM.
A virtual memory used in the general PC environment has changeable content. Thus, when the content is no longer needed in a caching buffer, changed content is rewritten to a disk so that the changed content can be henceforth referred to according to need. The mobile equipment performs demand paging for only unchangeable data (that is, read only data) and therefore, does not have to swap out content to the NAND flash memory, etc.
FIG. 1 is a flow diagram illustrating a conventional demand paging process.
In the case where a terminal intends to carry out a specific process, the terminal reads data stored in a flash memory.
Initially, the terminal secures a memory space in a RAM to store read data therein in step S101. Then, the terminal determines whether data to be loaded corresponds to read only data in step S102.
The read only data, an object of demand paging, is stored in a flash memory. On the other hand, data other than the read only data are all loaded into the RAM because they cannot be demand-paged.
Thus, if data corresponds to the read only data, the terminal takes the data from the flash memory through demand paging and temporarily stores the data in RAM in step S103.
On the other hand, the data other than the read only data are not objects of demand paging and thus, the terminal copies the data, which have been loaded into RAM, into a cashing buffer and temporarily stores the data in the cashing buffer in step S104.
Then, the terminal processes a specific process using the loaded data in step S105.
Thus, the demand paging technique provides an advantage of being capable of greatly reducing a needed capacity of RAM for code execution because an amount of RAM used for code execution can be reduced by a size of the caching buffer from a size of all of the code.
Demand paging is a technology suitable for use in mobile equipment requiring a strict real-time response that would not be tolerant to a delay of even 1 ms, because the demand paging has no write operation that would take a long time.
However, in the case where a NAND flash memory is used together with data storage, there is a problem. In the case where there is a request for demand paging while a file system performs write/erase for a NAND flash memory that is a shared resource in a mobile equipment operating in a multi-task mode, the demand paging has to wait until the file system finishes using the NAND flash memory. However, it takes a period of time on the order of several milliseconds (ms) for a storage type flash medium such as a conventional NAND flash to perform an erase, etc. and therefore, this causes a delay.
Because a delay of several ms cannot be tolerated in a protocol stack such as a phone function, even when there is a request for demand paging, it is determined whether the demand paging is applied by strictly separating code requiring a real-time response and a code that does not. However, this separation process requires a lot of effort and technology and further, it is difficult to distinguish the code in many cases. Thus, a considerable amount of code is classified as not being able to apply demand paging in order to ensure stability. The code classified as not being able to apply the demand paging are all loaded into RAM and therefore, there is a drawback of consuming a large amount of RAM resources.